import tensorflow as tf
from joblib import load
import pandas as pd
import numpy as np
from sklearn.preprocessing import StandardScaler
class Daima5(object):
    
    def __init__(self):
        self.loaded_model = tf.keras.models.load_model("D:/数据挖掘代码/git第一个项目/five/my_model.keras")
        self.scaler = load("D:/数据挖掘代码/git第一个项目/five/scaler.joblib")
        
        
    def get_hourly_trend(self):
        """模型预测结果获取"""
        
        
        n_steps = 7
        df_pivot = pd.read_csv("D:/数据挖掘代码/git第一个项目/five/scenic_data.csv")
        latest_data = df_pivot.iloc[-n_steps:].values
        latest_data = latest_data.reshape(1, n_steps,latest_data.shape[1])
        
        
        predicted = self.loaded_model.predict(latest_data)
        predicted_count = self.scaler.inverse_transform(predicted)
        predicted_count[predicted_count < 0] = 0
        
        hourly_trend = predicted_count[0].astype(int).tolist()
        print (hourly_trend)
        
        
if __name__ == '__main__':
    mwy = Daima5()
    mwy.get_hourly_trend()